@extends("admin.frame_layout")
<?php $top_selected = "工作台";$page_menu = "充值/扣款" ?>
@section('content')
    <div class="formbody">
        <form id="credit" action="{{route('admin.debit.act',['flag'=>\App\Models\MDebitLog::$USER_RECHARGE])}}"
              method="post">
            {{ csrf_field() }}
            <div class="formtitle"><span>账户充值</span></div>
            <ul class="forminfo">
                <li>
                    <label class="lable"><span class="info">*</span>账户类型</label>
                    <select name="type" id="cate">
                        <option value="{{\App\Models\MWallet::$WALLET_TYPE_1}}">{{uWalletStr(\App\Models\MWallet::$WALLET_TYPE_1)}}钱包</option>
                        <option value="{{\App\Models\MWallet::$WALLET_TYPE_2}}">{{uWalletStr(\App\Models\MWallet::$WALLET_TYPE_2)}}钱包</option>
                        <option value="{{\App\Models\MWallet::$WALLET_TYPE_3}}">{{uWalletStr(\App\Models\MWallet::$WALLET_TYPE_3)}}钱包</option>
                    </select>
                    <i for="cate"></i>
                </li>
                <li>
                    <label class="lable"><span class="info">*</span>充值会员</label>
                    <input name="uname" type="text" class="dfinput" placeholder="会员账号"/>
                    <i></i>
                </li>

                <li>
                    <label class="lable"><span class="info">*</span>充值金额</label>
                    <input name="money" type="number" class="dfinput" placeholder="0"/>
                    <i></i>
                </li>
                <li><label class="lable">&nbsp;</label><input type="submit" class="btn" value="确认充值"/></li>
            </ul>
        </form>
    </div>
    <div class="formbody">
        <form id="debit" action="{{route('admin.debit.act',['flag'=>\App\Models\MDebitLog::$USER_DEDUCTING])}}"
              method="post">
            <input name="_token" value="{{csrf_token()}}" type="hidden"/>

            <div class="formtitle"><span>账户扣款</span></div>
            <ul class="forminfo">
                <li>
                    <label class="lable"><span class="info">*</span>账户类型</label>
                    <select name="type" id="cate">
                        <option value="{{\App\Models\MWallet::$WALLET_TYPE_1}}">{{uWalletStr(\App\Models\MWallet::$WALLET_TYPE_1)}}钱包</option>
                        <option value="{{\App\Models\MWallet::$WALLET_TYPE_2}}">{{uWalletStr(\App\Models\MWallet::$WALLET_TYPE_2)}}钱包</option>
                        <option value="{{\App\Models\MWallet::$WALLET_TYPE_3}}">{{uWalletStr(\App\Models\MWallet::$WALLET_TYPE_3)}}钱包</option>
                    </select>
                    <i for="cate"></i>
                </li>
                <li>
                    <label class="lable"><span class="info">*</span>扣款会员</label>
                    <input name="uname" type="text" class="dfinput" placeholder="会员账号"/>
                    <i></i>
                </li>

                <li>
                    <label class="lable"><span class="info">*</span>扣款金额</label>
                    <input name="money" type="number" class="dfinput" placeholder="0"/>
                    <i></i>
                </li>
                <li><label class="lable">&nbsp;</label><input type="submit" class="btn" value="确认扣款"/></li>
            </ul>
        </form>
    </div>
@endsection

@section('footer')
    <script type="text/javascript">
        var rules = {uname: {required: true}, money: {required: true, number: true}};

        $("#credit").validate({
            rules: rules,
            submitHandler: submitHandler
        });

        $("#debit").validate({
            rules: rules,
            submitHandler: submitHandler
        });

        function submitHandler(form) {
            $(form).ajaxSubmit({
                dataType: "json",
                type: "post",
                success: function (data) {
                    if (data.code == 0) {
                        toastr['success'](data.msg);
                        window.location.reload();
                    } else {
                        toastr['error'](data.msg);
                    }
                }
            });
        }
    </script>
@endsection